package com.dpiinc.TechPage.utils

import android.content.res.Resources
import android.util.TypedValue
import com.dpiinc.TechPage.AIWriteApplication

/**
 * TODO name
 * Created by X on 2018/7/7.
 */
object AppUtil {
    fun dp2px(value: Float): Float {
        return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, Resources.getSystem().displayMetrics)
    }

    fun getVersion(): String {
        val packageManager = AIWriteApplication.instance().packageManager
        var version: String = ""
        try {
            val info = packageManager.getPackageInfo(AIWriteApplication.instance().packageName, 0)
            var verisonName = info.versionName
            version = "V" + verisonName
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return version
    }
}